﻿namespace TheSafety.Management
{
    using Agent;
    using System;
    using System.CodeDom.Compiler;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Linq;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Markup;

    [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
    public class ChangeItemNew : UserControl, IComponentConnector
    {
        private SynchronizationContext a;
        private bool aa;
        [CompilerGenerated]
        private string ab;
        [CompilerGenerated]
        private string ac;
        [CompilerGenerated]
        private string ad;
        [CompilerGenerated]
        private static Func<ManagementChangeInfoItem, bool> ae;
        [CompilerGenerated]
        private static Func<ManagementChangeInfoItem, bool> af;
        [CompilerGenerated]
        private static Func<ManagementChangeInfoItem, bool> ag;
        [CompilerGenerated]
        private static Func<ManagementChangeInfoItem, bool> ah;
        [CompilerGenerated]
        private static Func<ManagementChangeInfoItem, bool> ai;
        [CompilerGenerated]
        private static Func<ManagementChangeInfoItem, bool> aj;
        [CompilerGenerated]
        private static Func<ManagementChangeInfoItem, bool> ak;
        [CompilerGenerated]
        private static Func<ManagementChangeInfoItem, bool> al;
        [CompilerGenerated]
        private static Func<ManagementChangeInfoItem, bool> am;
        private EventHandler<RoutedEventArgs> b;
        private List<ManagementChangeInfoItem> c = new List<ManagementChangeInfoItem>();
        internal GroupBox d;
        internal Label e;
        internal Label f;
        internal Label g;
        internal Label h;
        internal RadioButton i;
        internal RadioButton j;
        internal RadioButton k;
        internal Label l;
        internal ComboBox m;
        internal Label n;
        internal Label o;
        internal Label p;
        internal Label q;
        internal GroupBox r;
        internal StackPanel s;
        internal Label t;
        internal Label u;
        internal StackPanel v;
        internal Label w;
        internal Label x;
        internal Button y;
        internal Button z;

        public ChangeItemNew()
        {
            this.InitializeComponent();
            this.a();
            this.i.Visibility = Visibility.Collapsed;
        }

        private void a()
        {
            this.z.Content = e.c("Back");
            this.y.Content = e.c("ChangeSubscription");
            this.g.Content = e.c("Expires") + ":";
            this.e.Content = e.c("OneSubscribtion") + ":";
            this.f.Content = e.c("VPNUsername") + ":";
            this.t.Content = e.c("Expires") + ":";
            this.w.Content = e.c("Left") + ":";
            this.l.Content = e.c("Subscription") + ":";
            this.h.Content = e.c("YouCanChangeSubscription") + ":";
            this.d.Header = e.c("OrderInfo");
            this.r.Header = e.c("Sum");
            this.i.Content = e.c("Return");
            this.j.Content = e.c("StandartVPN");
            this.k.Content = e.c("ViPN");
        }

        public void a(EventHandler<RoutedEventArgs> A_0)
        {
            EventHandler<RoutedEventArgs> handler2;
            EventHandler<RoutedEventArgs> b = this.b;
            do
            {
                handler2 = b;
                EventHandler<RoutedEventArgs> handler3 = (EventHandler<RoutedEventArgs>) Delegate.Remove(handler2, A_0);
                b = Interlocked.CompareExchange<EventHandler<RoutedEventArgs>>(ref this.b, handler3, handler2);
            }
            while (b != handler2);
        }

        [CompilerGenerated]
        private static bool a(ManagementChangeInfoItem A_0)
        {
            return (A_0.f() == "vipn");
        }

        private string a(DateTime A_0)
        {
            TimeSpan span = A_0.Subtract(DateTime.Now);
            return string.Concat(new object[] { span.Days, e.c("d"), " ", span.Hours, e.c("h"), " ", span.Minutes, e.c("m") });
        }

        [CompilerGenerated]
        private void a(object A_0)
        {
            if (ae == null)
            {
                ae = new Func<ManagementChangeInfoItem, bool>(ChangeItemNew.i);
            }
            if (this.c.Count<ManagementChangeInfoItem>(ae) > 0)
            {
                this.i.IsChecked = true;
                this.i.IsEnabled = true;
                this.i.Visibility = Visibility.Visible;
            }
            else
            {
                this.i.IsChecked = false;
                this.i.IsEnabled = false;
                this.i.Visibility = Visibility.Collapsed;
                if (af == null)
                {
                    af = new Func<ManagementChangeInfoItem, bool>(ChangeItemNew.h);
                }
                if (this.c.Count<ManagementChangeInfoItem>(af) > 0)
                {
                    this.j.IsChecked = true;
                }
                else
                {
                    this.k.IsChecked = true;
                }
            }
            this.radioReturn_Click(null, null);
        }

        private DateTime a(string A_0)
        {
            double result = 0.0;
            double.TryParse(A_0, out result);
            DateTime time = new DateTime(0x7b2, 1, 1, 0, 0, 0);
            return time.AddSeconds(result);
        }

        [EditorBrowsable(EditorBrowsableState.Never), DebuggerNonUserCode]
        private void a(int A_0, object A_1)
        {
            switch (A_0)
            {
                case 1:
                    ((ChangeItemNew) A_1).Loaded += new RoutedEventHandler(this.UserControl_Loaded);
                    return;

                case 2:
                    this.d = (GroupBox) A_1;
                    return;

                case 3:
                    this.e = (Label) A_1;
                    return;

                case 4:
                    this.f = (Label) A_1;
                    return;

                case 5:
                    this.g = (Label) A_1;
                    return;

                case 6:
                    this.h = (Label) A_1;
                    return;

                case 7:
                    this.i = (RadioButton) A_1;
                    this.i.Click += new RoutedEventHandler(this.radioReturn_Click);
                    return;

                case 8:
                    this.j = (RadioButton) A_1;
                    this.j.Click += new RoutedEventHandler(this.radioReturn_Click);
                    return;

                case 9:
                    this.k = (RadioButton) A_1;
                    this.k.Click += new RoutedEventHandler(this.radioReturn_Click);
                    return;

                case 10:
                    this.l = (Label) A_1;
                    return;

                case 11:
                    this.m = (ComboBox) A_1;
                    this.m.SelectionChanged += new SelectionChangedEventHandler(this.ddlPeriod_SelectionChanged);
                    return;

                case 12:
                    this.n = (Label) A_1;
                    return;

                case 13:
                    this.o = (Label) A_1;
                    return;

                case 14:
                    this.p = (Label) A_1;
                    return;

                case 15:
                    this.q = (Label) A_1;
                    return;

                case 0x10:
                    this.r = (GroupBox) A_1;
                    return;

                case 0x11:
                    this.s = (StackPanel) A_1;
                    return;

                case 0x12:
                    this.t = (Label) A_1;
                    return;

                case 0x13:
                    this.u = (Label) A_1;
                    return;

                case 20:
                    this.v = (StackPanel) A_1;
                    return;

                case 0x15:
                    this.w = (Label) A_1;
                    return;

                case 0x16:
                    this.x = (Label) A_1;
                    return;

                case 0x17:
                    this.y = (Button) A_1;
                    this.y.Click += new RoutedEventHandler(this.btnOk_Click);
                    return;

                case 0x18:
                    this.z = (Button) A_1;
                    this.z.Click += new RoutedEventHandler(this.btnCancel_Click);
                    return;
            }
            this.aa = true;
        }

        public void b(EventHandler<RoutedEventArgs> A_0)
        {
            EventHandler<RoutedEventArgs> handler2;
            EventHandler<RoutedEventArgs> b = this.b;
            do
            {
                handler2 = b;
                EventHandler<RoutedEventArgs> handler3 = (EventHandler<RoutedEventArgs>) Delegate.Combine(handler2, A_0);
                b = Interlocked.CompareExchange<EventHandler<RoutedEventArgs>>(ref this.b, handler3, handler2);
            }
            while (b != handler2);
        }

        [CompilerGenerated]
        private static bool b(ManagementChangeInfoItem A_0)
        {
            return (A_0.f() == "standard");
        }

        [CompilerGenerated]
        private void b(object A_0)
        {
            SendOrPostCallback d = null;
            <>c__DisplayClass6 class2;
            string a = "";
            this.a.Send(new SendOrPostCallback(class2.c), null);
            if (!string.IsNullOrWhiteSpace(a))
            {
                MessageBox.Show(a);
            }
            else
            {
                if (d == null)
                {
                    d = new SendOrPostCallback(this.a);
                }
                this.a.Send(d, null);
            }
        }

        private void btnCancel_Click(object A_0, RoutedEventArgs A_1)
        {
            if (this.b != null)
            {
                this.b(A_0, A_1);
            }
        }

        private void btnOk_Click(object A_0, RoutedEventArgs A_1)
        {
            ParameterizedThreadStart start = null;
            ParameterizedThreadStart start2 = null;
            <>c__DisplayClass14 class2;
            object d = A_0;
            RoutedEventArgs e = A_1;
            if (this.i.IsChecked.HasValue && this.i.IsChecked.Value)
            {
                if (ag == null)
                {
                    ag = new Func<ManagementChangeInfoItem, bool>(ChangeItemNew.g);
                }
                if (this.c.Count<ManagementChangeInfoItem>(ag) > 0)
                {
                    if (start == null)
                    {
                        start = new ParameterizedThreadStart(class2.g);
                    }
                    Thread thread = new Thread(start) {
                        IsBackground = true
                    };
                    object[] parameter = new object[2];
                    parameter[0] = this.b();
                    if (ah == null)
                    {
                        ah = new Func<ManagementChangeInfoItem, bool>(ChangeItemNew.f);
                    }
                    parameter[1] = this.c.Single<ManagementChangeInfoItem>(ah).b();
                    thread.Start(parameter);
                }
            }
            else
            {
                if (start2 == null)
                {
                    start2 = new ParameterizedThreadStart(class2.h);
                }
                new Thread(start2) { IsBackground = true }.Start(new object[] { this.b(), (this.m.SelectedItem as ComboBoxItem).Tag });
            }
        }

        [CompilerGenerated]
        private static bool c(ManagementChangeInfoItem A_0)
        {
            return A_0.c();
        }

        [CompilerGenerated]
        private static bool d(ManagementChangeInfoItem A_0)
        {
            return A_0.c();
        }

        private void ddlPeriod_SelectionChanged(object A_0, SelectionChangedEventArgs A_1)
        {
            if (this.m.SelectedItem != null)
            {
                this.u.Content = ((this.m.SelectedItem as ComboBoxItem).Tag as ManagementChangeInfoItem).a();
                this.x.Content = ((this.m.SelectedItem as ComboBoxItem).Tag as ManagementChangeInfoItem).d();
            }
            else
            {
                this.u.Content = this.x.Content = "";
            }
        }

        [CompilerGenerated]
        private static bool e(ManagementChangeInfoItem A_0)
        {
            return A_0.c();
        }

        [CompilerGenerated]
        private static bool f(ManagementChangeInfoItem A_0)
        {
            return A_0.c();
        }

        [CompilerGenerated]
        private static bool g(ManagementChangeInfoItem A_0)
        {
            return A_0.c();
        }

        [CompilerGenerated]
        private static bool h(ManagementChangeInfoItem A_0)
        {
            return (A_0.f() == "standard");
        }

        [CompilerGenerated]
        private static bool i(ManagementChangeInfoItem A_0)
        {
            return A_0.c();
        }

        [DebuggerNonUserCode]
        public void InitializeComponent()
        {
            if (!this.aa)
            {
                this.aa = true;
                Uri resourceLocator = new Uri("/TheSafety;component/management/changeitemnew.xaml", UriKind.Relative);
                Application.LoadComponent(this, resourceLocator);
            }
        }

        private void radioReturn_Click(object A_0, RoutedEventArgs A_1)
        {
            this.m.Items.Clear();
            if (this.i.IsChecked.HasValue && this.i.IsChecked.Value)
            {
                this.q.Visibility = Visibility.Visible;
                this.m.Visibility = Visibility.Hidden;
                if (ai == null)
                {
                    ai = new Func<ManagementChangeInfoItem, bool>(ChangeItemNew.e);
                }
                this.q.Content = this.c.Single<ManagementChangeInfoItem>(ai).e();
                if (aj == null)
                {
                    aj = new Func<ManagementChangeInfoItem, bool>(ChangeItemNew.d);
                }
                this.u.Content = this.c.Single<ManagementChangeInfoItem>(aj).a();
                if (ak == null)
                {
                    ak = new Func<ManagementChangeInfoItem, bool>(ChangeItemNew.c);
                }
                this.x.Content = this.c.Single<ManagementChangeInfoItem>(ak).d();
            }
            else if (this.j.IsChecked.HasValue && this.j.IsChecked.Value)
            {
                if (al == null)
                {
                    al = new Func<ManagementChangeInfoItem, bool>(ChangeItemNew.b);
                }
                foreach (ManagementChangeInfoItem item in this.c.Where<ManagementChangeInfoItem>(al))
                {
                    ComboBoxItem newItem = new ComboBoxItem {
                        Content = item.e(),
                        Tag = item
                    };
                    this.m.Items.Add(newItem);
                }
                this.m.SelectedIndex = 0;
                if (this.m.Items.Count > 0)
                {
                    this.q.Visibility = Visibility.Hidden;
                    this.m.Visibility = Visibility.Visible;
                }
                else
                {
                    this.q.Visibility = Visibility.Visible;
                    this.m.Visibility = Visibility.Hidden;
                    this.q.Content = e.c("NoSubscriptionsToChange");
                }
            }
            else if (this.k.IsChecked.HasValue && this.k.IsChecked.Value)
            {
                if (am == null)
                {
                    am = new Func<ManagementChangeInfoItem, bool>(ChangeItemNew.a);
                }
                foreach (ManagementChangeInfoItem item3 in this.c.Where<ManagementChangeInfoItem>(am))
                {
                    ComboBoxItem item4 = new ComboBoxItem {
                        Content = item3.e(),
                        Tag = item3
                    };
                    this.m.Items.Add(item4);
                }
                this.m.SelectedIndex = 0;
                if (this.m.Items.Count > 0)
                {
                    this.q.Visibility = Visibility.Hidden;
                    this.m.Visibility = Visibility.Visible;
                }
                else
                {
                    this.q.Visibility = Visibility.Visible;
                    this.m.Visibility = Visibility.Hidden;
                    this.q.Content = e.c("NoSubscriptionsToChange");
                }
            }
        }

        private void ShowResult(bool A_0, string A_1, object A_2, RoutedEventArgs A_3)
        {
            if (!string.IsNullOrWhiteSpace(A_1))
            {
                MessageBox.Show(A_1);
            }
            if (A_0)
            {
                this.btnCancel_Click(A_2, A_3);
                ConfigManager.j();
            }
            else
            {
                MessageBox.Show(e.c("Error"));
            }
        }

        private void UserControl_Loaded(object A_0, RoutedEventArgs A_1)
        {
            this.a = SynchronizationContext.Current;
            this.p.Content = this.a(this.c()).ToShortDateString() + " (" + this.a(this.a(this.c())) + ")";
            new Thread(new ParameterizedThreadStart(this.b)) { IsBackground = true }.Start(null);
        }

        public string PropDate
        {
            [CompilerGenerated]
            get
            {
                return this.ab;
            }
            [CompilerGenerated]
            set
            {
                this.ab = value;
            }
        }

        public string PropOrderID
        {
            [CompilerGenerated]
            get
            {
                return this.ac;
            }
            [CompilerGenerated]
            set
            {
                this.ac = value;
            }
        }

        public string PropSubscription
        {
            set
            {
                this.n.Content = value;
            }
        }

        public string PropUserName
        {
            set
            {
                this.o.Content = value;
            }
        }

        public string PropWhile
        {
            [CompilerGenerated]
            get
            {
                return this.ad;
            }
            [CompilerGenerated]
            set
            {
                this.ad = value;
            }
        }
    }
}

